﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Diagnostics;

namespace Fulcrum.ViewModelGenerator.UnitTests
{
    static class XmlHelper
    {
        public static XDocument CreateMinimalViewModelCollection()
        {
            return new XDocument(new XElement("ViewModels",
                                    new XAttribute("Company", "Company"),
                                    new XAttribute("Copyright", "Copyright")));
        }

        public static XDocument CreateViewModelCollection(List<string> viewModelNames)
        {
            Debug.Assert(null != viewModelNames);

            var doc = CreateMinimalViewModelCollection();
            var element = doc.Element("ViewModels");
            viewModelNames.ForEach(n => element.Add(CreateMinimalViewModel(n)));

            return doc;
        }

        public static XElement CreateMinimalViewModel(string name)
        {
            return new XElement("ViewModel",
                        new XAttribute("Name", name),
                        new XAttribute("Summary", "Summary"));
        }

        public static XElement CreateMinimalViewModelProperty(string name)
        {
            return new XElement("Property",
                new XAttribute("Name", name),
                new XAttribute("Type", "Type"),
                new XAttribute("DefaultValue", "DefaultValue"),
                new XAttribute("Summary", "Summary"));
        }

        public static XElement CreateMinimalViewModelEvent(string name)
        {
            return new XElement("Event",
                new XAttribute("Name", name),
                new XAttribute("EventArgsType", "EventArgsType"),
                new XAttribute("Summary", "Summary"));
        }
    }

}
